﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IList<MethodCategoryInfo>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Method Category - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Method Manage &gt; Category &gt; Category List</legend>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td width="120">
                    <strong>Category Code</strong>
                </td>
                <td width="120" align="center">
                    <strong>Category Name</strong>
                </td>
                <td width="120">
                    <strong>Category Order</strong>
                </td>
                <td align="center">
                    <strong>Manage</strong>
                </td>
            </tr>
            <%
                foreach (MethodCategoryInfo category in Model)
                {
            %>
            <tr>
                <td>
                    <%= category.CATEGORY_CD%>
                </td>
                <td width="70" align="center">
                    <%= category.CATEGORY_NAME%>
                </td>
                <td>
                    <%= category.CATEGORY_ORDER%>
                </td>
                <td width="120" align="center">
                    [<%= Html.ActionLink("Modify", "CategoryMod", "Method", new { id = category.CATEGORY_CD }, null)%>]
                    [<a href="javascript:void(0);" onclick="javascript:Delete('<%=category.CATEGORY_CD %>');">Delete</a>]
                </td>
            </tr>
            <%
                }
            %>
        </table>
        <input type="button" id="btnAddCategory" name="btnAddCategory" value="Add Category" />
    </fieldset>

    <script type="text/javascript" language="javascript">

        $().ready(function() {
            $("#btnAddCategory").click(function() {
                location.href = "/Method/CategoryAdd";
            })
        })

        function Delete(category_cd) {
        
            if (confirm('Are you sure delete?')) {
               
                $.post("/Method/AjaxCategoryDel?" + new Date(), {
                    Action: "post",
                    category_cd: category_cd
                }, function(result) {
                    if (result.FLAG) {
                        alert(result.DESC);
                        location.href = "/Method/CategoryList";
                    }
                    else {
                        alert(result.DESC);
                    }
                })
            }
        }


    </script>

</asp:Content>
